<?php
	defined('_JEXEC') or die('Restricted access');
    //
    require_once(CUTEENGINE_BASE_COMPONENTS_PATH."header_script_generator_class.php");
	require_once(CUTEENGINE_BASE_COMPONENTS_PATH."content_loader_class.php");
    require_once(CUTEENGINE_BASE_COMPONENTS_PATH."user_agent_class.php");
    //
    // t_javascript_code_generator
    //
    class t_javascript_code_generator_element
    {
        // Primary condition
		const t_primary_condition_type_no_condition = 1;
		const t_primary_condition_type_browser = 2;
		// Cmparison type
		const t_comparison_type_equal = 1;
		const t_comparison_type_not_equal = 2;
		const t_comparison_type_less_than = 3;
		const t_comparison_type_greater_than = 4;
		const t_comparison_type_less_than_or_equal_to = 5; 
		const t_comparison_type_greater_than_or_equal_to = 6;
        //
		// property declaration
		//public
		// C
		public $comparison_type_equal = null; //t_comparison_type;
        // P
        public $primary_condition_type = null; //t_primary_condition;
        // R 
		public $result_value_else = null;
        public $result_value = null; 
        // S
        public $secondary_condition_type = null; //various type;
        //  U
		public $user_agent = false; // t_user_agent_component;        
		//  T
		public $tertiary_condition_type = null; //various type;
		// method declaration
		// public
        public function __construct($a_primary_condition_type,
            $a_secondary_condition_type,$a_tertiary_condition_type,
			$a_comparison_type_equal,$a_result_value,
			$a_result_value_else) 
		{
			$this->user_agent = new t_user_agent_component;
			//$local_user_agent = $this->user_agent;		
			$this->primary_condition_type = $a_primary_condition_type;
            $this->secondary_condition_type = $a_secondary_condition_type;
			$this->tertiary_condition_type = $a_tertiary_condition_type;
			$this->comparison_type_equal = $a_comparison_type_equal;
            $this->result_value = $a_result_value; 
			$this->result_value_else = $a_result_value_else; 
        }  
        //  G  //
        public function generate_code()
        {
            //global $g_javascript_namespace;
			$local_user_agent = $this->user_agent;
			//echo "local_user_agent->browser:". $local_user_agent->browser;
            //
            $local_return = '';
			switch ($this->primary_condition_type) 
			{
				/*  self::t_primary_condition_type_no_condition:  */
				case self::t_primary_condition_type_no_condition:
					$local_return = $this->result_value; 
					break;
				/*  self::t_primary_condition_type_browser  */	
				case self::t_primary_condition_type_browser:
					if (!isset($this->tertiary_condition_type))
					{
						if ((($this->comparison_type_equal == self::t_comparison_type_equal) &&
							($this->secondary_condition_type === $local_user_agent->browser)) ||
							(($this->comparison_type_equal == self::t_comparison_type_not_equal) &&
							($this->secondary_condition_type !== $local_user_agent->browser)))
							$local_return = $this->result_value; 
						else
							$local_return = $this->result_value_else; 
					}
					else 
					{
						if ((($this->comparison_type_equal == self::t_comparison_type_equal) &&
							((int)$this->tertiary_condition_type === (int)$local_user_agent->browser_version)) ||
							(($this->comparison_type_equal == self::t_comparison_type_not_equal) &&
							((int)$this->tertiary_condition_type !== (int)$local_user_agent->browser_version)) ||
							(($this->comparison_type_equal == self::t_comparison_type_less_than) &&
							((int)$this->tertiary_condition_type < (int)$local_user_agent->browser_version)) ||
							(($this->comparison_type_equal == self::t_comparison_type_greater_than) &&
							((int)$this->tertiary_condition_type > (int)$local_user_agent->browser_version)) ||
							(($this->comparison_type_equal == self::t_comparison_type_less_than_or_equal_to) &&
							((int)$this->tertiary_condition_type <= (int)$local_user_agent->browser_version)) ||
							(($this->comparison_type_equal == self::t_comparison_type_greater_than_or_equal_to) &&
							((int)$this->tertiary_condition_type >= (int)$local_user_agent->browser_version)))
							$local_return = $this->result_value; 
						else
							$local_return = $this->result_value_else; 
					}
					break;
			
			}
			return $local_return;
        }
        
    }
    
    //
    // t_javascript_code_generator
    //
    class t_javascript_code_generator
    {
		// property declaration
		//public
		public $elements_list = array();		
		// method declaration
		// public
        public function __construct() 
		{
        }
        //  A  //
        public function add_text_with_condition_browser_type(
			$a_browser_type,$a_comparison_type_equal,$a_text,$a_else_text = '')
        {
			$local_element = new t_javascript_code_generator_element(
				t_javascript_code_generator_element::t_primary_condition_type_browser,
				$a_browser_type,null,$a_comparison_type_equal,$a_text,$a_else_text);
			$this->elements_list[] = $local_element;	
		}
		//
        public function add_text_with_condition_browser_type_and_version(
			$a_browser_type,$a_browser_version,$a_comparison_type_equal,
			$a_text,$a_else_text = '')
        {
			$local_element = new t_javascript_code_generator_element(
				t_javascript_code_generator_element::t_primary_condition_type_browser,
				$a_browser_type,$a_browser_version,$a_comparison_type_equal,
				$a_text,$a_else_text);
			$this->elements_list[] = $local_element;	
		}
		//
        public function add_text_without_condition($a_text)
        {
			$local_element = new t_javascript_code_generator_element(
				t_javascript_code_generator_element::t_primary_condition_type_no_condition,
				null,null,null,$a_text,'');
			$this->elements_list[] = $local_element;	
		}		
		// C
        public function compute_code() 
		{
			$local_return = '';
			foreach ($this->elements_list as $local_element_index => $local_element) 
			{
				//echo "$local_element_index <br>";
				$local_return .= $local_element->generate_code();
			}
			return $local_return;
        }

		//  R
        public function reset() 
		{
			unset($this->elements_list);
        }
		
	}
    
	//
    // t_javascript_namespace
    //
    class t_javascript_namespace
	{
		// property declaration
		//public
		//C
		public $content_loader = null; //t_content_loader;
		// E
		public $execution_of_javascript_object_method_to_body_event_list = array(array(array()));
		// H 
		public $header_script_generator = null; //t_header_script_generator;
		// J
		//public $javascript_body_events = array();	
		//public $javascript_body_events_delayed = array();		
        // O
		public $optimize = false;
        // U
        public $user_agent = false; // t_user_agent_component;        
		// method declaration
		// public
        public function __construct() 
		{
			$this->user_agent = new t_user_agent_component;
			$local_user_agent = $this->user_agent;
			//echo "local_user_agent->browser:". $local_user_agent->browser;
			//echo "<br>this->header_script_generator: "; print_r($this->header_script_generator); echo "<br>";
            $this->header_script_generator = new t_header_script_generator;
            $this->initilize_javascript_script();
			$this->content_loader = new t_content_loader($this,$this);
			$this->content_loader->initialize_parameter('undefined',
				'undefined','undefined','undefined',
				'undefined','undefined',false);	
            
        }
		// I
		public function initilize_javascript_script()
        {			
			$local_code_generator = new t_javascript_code_generator;
			// ARRAY
			// E
			$this->header_script_generator->add_method_to_a_class("Array",
				"exists","value");
			$this->header_script_generator->add_content_to_a_method("Array",
				"exists","
		/*for(var i = 0; i<this.length; i++) 
			if(this[i] == value) 
				return true;*/
        return (this.indexOf(value) > -1);");
			// R
		    $this->header_script_generator->add_method_to_a_class("Array",
				"remove","value");
			$this->header_script_generator->add_content_to_a_method("Array",
				"remove","
        for(var i = 0; i<this.length; i++) 
			if(this[i] == value) 
				this.splice(i,1);");
			// FUNCTION 
			// I
		    $this->header_script_generator->add_method_to_a_class("Function",
				"inherits","superclass");				
			$this->header_script_generator->add_content_to_a_method("Function",
				"inherits","
        if ((superclass.prototype.parent_class != '') && (superclass.prototype.parent_class != undefined)) 
            this.inherits(superclass.prototype.parent_class);
        superclass.call(this.prototype);
		this.prototype.parent_class = superclass;
        this.prototype.constructor = this;
        ");
        // String
        // A        
            $this->header_script_generator->add_method_to_a_class_with_content("String",
                "addslashes","","
        var local_string = this.toString();        
        local_string = local_string.replace(/\\\\/g,'\\\\\\\');
        local_string = local_string.replace(/\'/g,'\\\\\'');
        local_string = local_string.replace(/\\\"/g,'\\\\\"');
        var local_pattern = new RegExp(\"\\0\", \"g\");
        local_string = local_string.replace(local_pattern,'\\\\0');
        return local_string;
        ");
            // L
            $this->header_script_generator->add_method_to_a_class_with_content("String",
                "ltrim","","
        var local_string = this.toString();
        return local_string.replace(/^\s+/,'');");
            // R
            $this->header_script_generator->add_method_to_a_class_with_content("String",
                "rtrim","","
        var local_string = this.toString();
        return local_string.replace(/\s+$/,'');");
            // S
			$this->header_script_generator->add_method_to_a_class_with_content("Function",
				"set_scope","obj", "
		var method = this;
		var init_args = [];
		for(var i = 1; i<arguments.length; i++) init_args.push(arguments[i]);
		temp = function() {
			var args = [];
			//alert('arguments.length:'+arguments.length);
			for(var i = 0; i<init_args.length; i++) args.push(init_args[i]);
			for(var i = 0; i<arguments.length; i++) args.push(arguments[i]);
			//alert('dopo for - args.length:'+args.length);
            if ((window.event != undefined) && (window.event.which === undefined)) args.push(event);
			return method.apply(obj, args);
		};
		return temp;");
            $this->header_script_generator->add_method_to_a_class_with_content("String",
                "stripslashes","","
        var local_string = this.toString();
        local_string = local_string.replace(/\\\\'/g,'\'');
        local_string = local_string.replace(/\\\\\"/g,'\"');
        local_string = local_string.replace(/\\\\0/g,'\0');
        local_string = local_string.replace(/\\\\\\\\/g,'\\\\');
        return local_string;
        ");        
            // T
            $this->header_script_generator->add_method_to_a_class_with_content("String",
                "trim","","
        var local_string = this.toString();
        return local_string.replace(/^\s+|\s+$/g,'');");
            // V
			$this->header_script_generator->add_method_to_a_class_with_content("String",
                "validate_email","a_email",'var re = /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;'."
    return re.test(a_email);");
			$this->header_script_generator->add_method_to_a_class_with_content("String",
                "validate_link","a_link",'var re = /^(https?|ftp|file):\/\/.+$/i;'."
    return re.test(a_link);");

            // MAIN SCOPE
            // A
            $this->header_script_generator->add_function_to_main_scope(
                "addCSSRule","ruleName"," 
            if (document.styleSheets) 
            {
                if (!get_css_rule(ruleName)) 
                {
                    if (document.styleSheets[0].addRule) 
                    {
                        document.styleSheets[0].addRule(ruleName, null,0);
                    } 
                    else 
                    {
                        document.styleSheets[0].insertRule(ruleName+' { }', 0);
                    }
                }
            }
            return get_css_rule(ruleName);"); 

            $this->header_script_generator->add_function_to_main_scope(
                "add_value_to_position_value","current_value,value_to_add","
            return parseInt(current_value) + parseInt(value_to_add) + 'px';");
			// D
			global $g_ambient_namespace;
			//echo "this->user_agent->browser_version: ". (int)$this->user_agent->browser_version."<br>";
			global $g_javascript_namespace;
			if (($g_ambient_namespace->user_agent->browser == t_user_agent_component::t_browser_ie) &&
				((int)$g_ambient_namespace->user_agent->browser_version < 9))
			{
				$local_body_function = "a_item.click();
				";/*"
                        var clickEvent = document.createEventObject (window.event);
                        clickEvent.button = 1;  // left click
                        a_item.fireEvent (\"onclick\", clickEvent);*/
				
				
			}
			else
			{
				$local_body_function = "
					var mousedownEvent = document.createEvent (\"MouseEvent\");
					mousedownEvent.initMouseEvent (\"click\", true, true, window, 0, 
						event.screenX, event.screenY, event.clientX, event.clientY, 
						event.ctrlKey, event.altKey, event.shiftKey, event.metaKey, 
						0, a_item);
					a_item.dispatchEvent (mousedownEvent);";
			}
			$this->header_script_generator->add_function_to_main_scope(
				"do_click","event,a_item","
        $local_body_function
		");
            // I
            $this->header_script_generator->add_function_to_main_scope(
                "initialize_size_window",""," 
            if( typeof( window.innerWidth ) == 'number' ) 
            {
                //Non-IE
                g_window_width = window.innerWidth;
                g_window_height = window.innerHeight;
            } 
            else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
            {
                //IE 6+ in 'standards compliant mode'
                g_window_width = document.documentElement.clientWidth;
                g_window_height = document.documentElement.clientHeight;
            }
            else 
            if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
            {
                //IE 4 compatible
                g_window_width = document.body.clientWidth;
                g_window_height = document.body.clientHeight;
            }");
            // G
            $this->header_script_generator->add_function_to_main_scope(
                "get_css_rule","ruleName, deleteFlag"," 
            ruleName=ruleName.toLowerCase();
            if (document.styleSheets) 
            {
                for (var i=0; i<document.styleSheets.length; i++) 
                {
                    var styleSheet=document.styleSheets[i];
                    var ii=0;
                    var cssRule=false;
                    do 
                    {
                        if (styleSheet.cssRules) 
                        {
                            cssRule = styleSheet.cssRules[ii];
                        } 
                        else 
                        {
                            cssRule = styleSheet.rules[ii];
                        }                                             
                        if (cssRule)  
                        {                               
                            if (cssRule.selectorText.toLowerCase()==ruleName) 
                            {
                                if (deleteFlag=='delete') 
                                {
                                    if (styleSheet.cssRules) 
                                    {
                                        styleSheet.deleteRule(ii);
                                    } 
                                    else 
                                    {
                                        styleSheet.removeRule(ii);
                                    }
                                    return true;
                                } 
                                else 
                                {
                                    return cssRule;
                                }
                            }
                        }
                        ii++;
                    } while (cssRule)
                }
            }
            return false;
            ");
            $this->header_script_generator->add_function_to_main_scope(
                "get_selection_end","o","
			try
			{
				
				if ((o.createTextRange) && (document != undefined) && (document.selection != undefined))
				{
					var r = document.selection.createRange().duplicate();
					r.moveStart('character', -o.value.length);
					return r.text.length;
				} 
				else
				{		
					
					return o.selectionEnd;
				}
				
			}
			catch(e)
			{
				//alert('is_read_ready: ' + is_read_ready + ' - ready: ' + ready+ ' - e:'+e );
				/*alert('errore 11');*/
				if (this.owner != window.cuteengine)
					window.cuteengine.add_err_log(e);
			}
            ");
            $this->header_script_generator->add_function_to_main_scope(
                "get_selection_start","o"," 
            if ((o.createTextRange) && (document != undefined) && (document.selection != undefined))
            {
                var r = document.selection.createRange().duplicate();
                r.moveEnd('character', o.value.length);
                if (r.text == '') 
                    return o.value.length;
                return o.value.lastIndexOf(r.text);
            } 
            else 
                return o.selectionStart;
            ");
            // K
            $this->header_script_generator->add_function_to_main_scope(
                "killCSSRule","ruleName"," 
            return get_css_rule(ruleName,'delete');");
            // G
			$local_code_generator->reset();
            $local_code_generator->add_text_with_condition_browser_type(
				t_user_agent_component::t_browser_ie,
				t_javascript_code_generator_element::t_comparison_type_equal,"
		var local_computed_style = element.currentStyle;","
		var local_computed_style = window.getComputedStyle (element, \"\");");
            $local_code_generator->add_text_without_condition("
		return local_computed_style;");
			// H
			$this->header_script_generator->add_function_to_main_scope(
                "hide_separator","a_string","
		var local_return = '';
		if (a_string == undefined)
			return local_return;
		var arr = {};
        arr[\"".t_url_parameter::ampersand_format."\"] = \"".t_url_parameter::hide_ampersand."\";
		arr[\"".t_url_parameter::method_format."\"] = \"".t_url_parameter::hide_method."\";
		arr[\"".t_url_parameter::argument_format."\"] = \"".t_url_parameter::hide_argument."\";	
		arr[\"".t_url_parameter::component_format."\"] = \"".t_url_parameter::hide_component."\";
		arr[\"".t_url_parameter::separator_level_1."\"] = \"".t_url_parameter::hide_separator_level_1."\";	
		arr[\"".t_url_parameter::separator_level_0."\"] = \"".t_url_parameter::hide_separator_level_0."\";	
        
		for (var i = 0; i<a_string.length; i++) 
		{
			if (arr[a_string.charAt(i)])
				local_return += arr[a_string.charAt(i)];
            else if ((arr[a_string.charAt(i) + a_string.charAt(i+1)]))
			{
				local_return += (arr[a_string.charAt(i) + a_string.charAt(i+1)]);
				i++;
			}	
			else
                local_return += a_string.charAt(i);
		}
        return local_return;
			");	
			$this->header_script_generator->add_function_to_main_scope(
                "get_computed_style","element",$local_code_generator->compute_code()/*"
            if (window.getComputedStyle) {
                var local_computed_style = window.getComputedStyle (element, \"\");
            }
            else {
                var local_computed_style = element.currentStyle;
            }
            return local_computed_style;"*/);
             
            $this->header_script_generator->add_function_to_main_scope(
                "get_bottom_value","a_tag,a_unit","
            local_return = 0;
            if (a_tag.style.bottom == '')
            {
                initialize_size_window();
                local_return = g_window_height -
                    (parseInt(a_tag.style.top) + parseInt(get_height_value(a_tag,a_unit)));
            }
            else
                local_return = parseInt(a_tag.style.bottom);
            return local_return + a_unit;");
            //
            /*$this->header_script_generator->add_function_to_main_scope(
                "get_default_position","","
            return 'absolute';");*/
            //
            $this->header_script_generator->add_function_to_main_scope(
                "get_height_value","a_tag,a_unit,a_plus","
                        local_return = 0;
			if (!a_tag)
				return local_return + a_unit;
			if (a_tag.getBoundingClientRect) 
			{
                var rect = a_tag.getBoundingClientRect ();
                local_return = rect.bottom - rect.top + a_plus;
            }
            else
			{ 
				local_return = parseInt(a_tag.offsetHeight) + a_plus;
			}
            return local_return + a_unit;");
            //
            $this->header_script_generator->add_function_to_main_scope(
                "get_left_value","a_tag,a_unit","
            local_return = 0;
            if (a_tag.style.left == '')
                local_return = parseInt(a_tag.offsetLeft);
            else
                local_return = parseInt(a_tag.style.left);
            return local_return + a_unit;");
            //
            /*$this->header_script_generator->add_function_to_main_scope(
                "get_position","a_tag","
            local_return = get_default_position();
            if (a_tag.style.position != '')
            {
                local_return = a_tag.style.position;
            }
            else if (((local_css_rule = get_css_rule('#'+a_tag.id)) != false) &&
                ((local_position = local_css_rule.cssText.indexOf('position:')) > -1))
            {
                local_return = local_css_rule.cssText.substring(local_position+9, 
                    local_css_rule.cssText.indexOf(';',local_position));
            }
            else if (((local_css_rule = get_css_rule('.'+a_tag.className)) != false) &&
                ((local_position = local_css_rule.cssText.indexOf('position:')) > -1))
            {
                local_return = local_css_rule.cssText.substring(local_position+9, 
                    local_css_rule.cssText.indexOf(';',local_position));
            }
            return local_return;");*/
            //    
            $this->header_script_generator->add_function_to_main_scope(
                "get_right_value","a_tag,a_unit","
            local_return = 0;
            if (a_tag.style.right == '')
            {
                initialize_size_window();
                local_return = g_window_width -
                    (parseInt(a_tag.style.left) + parseInt(get_width_value(a_tag,a_unit)));
            }
            else
                local_return = parseInt(a_tag.style.right);
            return local_return + a_unit;");
            //            
            $this->header_script_generator->add_function_to_main_scope(
                "get_top_value","a_tag,a_unit","
            local_return = 0;
            if (a_tag.style.top == '')
                local_return=parseInt(a_tag.offsetTop);
            else
                local_return = parseInt(a_tag.style.top);
            return local_return + a_unit;");
            //
            $this->header_script_generator->add_function_to_main_scope(
                "get_width_value","a_tag,a_unit,a_plus","
            local_return = 0;
			if (!a_tag)
				return local_return + a_unit;
			if (a_tag.getBoundingClientRect) 
			{
                var rect = a_tag.getBoundingClientRect ();
                local_return = rect.right - rect.left + a_plus;
            }
            else
			{ 
				local_return = parseInt(a_tag.offsetWidth) + a_plus;
			}
            return local_return + a_unit;");
            // S
            $this->header_script_generator->add_function_to_main_scope(
                "set_size","a_source,a_destination","
            local_source_style = get_computed_style(a_source);
            if (a_destination.ce_extension == undefined)
			{
				if (local_source_style.zIndex != 'auto')
					a_destination.style.zIndex = parseInt(local_source_style.zIndex) + 1;
				a_destination.style.position = local_source_style.position;
				a_destination.style.position = local_source_style.position;
				a_destination.style.left = local_source_style.left;
				a_destination.style.top = local_source_style.top;
				if (local_source_style.width != '')
				{
					a_destination.style.width = local_source_style.width;
				}    
				else
				{
					a_destination.style.right = local_source_style.right;
					a_destination.style.width = '';
				}    
				/* */
				a_destination.style.marginLeft = local_source_style.marginLeft;
				a_destination.style.borderLeftStyle = local_source_style.borderLeftStyle;
				a_destination.style.borderLeftWidth = local_source_style.borderLeftWidth;
				a_destination.style.paddingLeft = local_source_style.paddingLeft;
				/* */
				a_destination.style.marginRight = local_source_style.marginRight;
				a_destination.style.borderRightStyle = local_source_style.borderRightStyle;
				a_destination.style.borderRightWidth = local_source_style.borderRightWidth;
				a_destination.style.paddingRight = local_source_style.paddingRight;
				
				if (a_source.style.height != '')
				{
					a_destination.style.height = local_source_style.height;					
				}    
				else
				{
					a_destination.style.bottom = local_source_style.bottom;
					a_destination.style.height = '';
				}    
				/* */
				a_destination.style.marginTop = local_source_style.marginTop;
				a_destination.style.borderTopStyle = local_source_style.borderTopStyle;
				a_destination.style.borderTopWidth = local_source_style.borderTopWidth;
				a_destination.style.paddingTop = local_source_style.paddingTop;
				/* */
				a_destination.style.marginBottom = local_source_style.marginBottom;
				a_destination.style.borderBottomStyle = local_source_style.borderBottomStyle;
				a_destination.style.borderBottomWidth = local_source_style.borderBottomWidth;
				a_destination.style.paddingBottom = local_source_style.paddingBottom;					
				a_destination.style.visibility = '';
			}
			else
			{
				if (local_source_style.zIndex != 'auto')
					a_destination.ce_extension.change_style('zIndex', parseInt(local_source_style.zIndex) + 1);
				a_destination.ce_extension.change_style('position',local_source_style.position);
				a_destination.ce_extension.change_style('left',local_source_style.left);
				a_destination.ce_extension.change_style('top',local_source_style.top);
				if (local_source_style.width != '')
				{
					a_destination.ce_extension.change_style('width',local_source_style.width);
				}    
				else
				{
					a_destination.ce_extension.change_style('right',local_source_style.right);
					a_destination.ce_extension.change_style('width',local_source_style.width);
				}    
				/* */
				a_destination.ce_extension.change_style('marginLeft',local_source_style.marginLeft);
				a_destination.ce_extension.change_style('borderLeftStyle',local_source_style.borderLeftStyle);
				a_destination.ce_extension.change_style('borderLeftWidth',local_source_style.borderLeftWidth);
				a_destination.ce_extension.change_style('paddingLeft',local_source_style.paddingLeft);
				/* */
				a_destination.ce_extension.change_style('marginRight',local_source_style.marginRight);
				a_destination.ce_extension.change_style('borderRightStyle',local_source_style.borderRightStyle);
				a_destination.ce_extension.change_style('borderRightWidth',local_source_style.borderRightWidth);
				a_destination.ce_extension.change_style('paddingRight',local_source_style.paddingRight);

				if (a_source.style.height != '')
				{
					a_destination.ce_extension.change_style('height',local_source_style.height);
				}    
				else
				{
					a_destination.ce_extension.change_style('bottom',local_source_style.bottom);
					a_destination.ce_extension.change_style('height',local_source_style.height);
				}    
				/* */
				a_destination.ce_extension.change_style('marginTop',local_source_style.marginTop);
				a_destination.ce_extension.change_style('borderTopStyle',local_source_style.borderTopStyle);
				a_destination.ce_extension.change_style('borderTopWidth',local_source_style.borderTopWidth);
				a_destination.ce_extension.change_style('paddingTop',local_source_style.paddingTop);
				/* */
				a_destination.ce_extension.change_style('marginBottom',local_source_style.marginBottom);
				a_destination.ce_extension.change_style('borderBottomStyle',local_source_style.borderBottomStyle);
				a_destination.ce_extension.change_style('borderBottomWidth',local_source_style.borderBottomWidth);
				a_destination.ce_extension.change_style('paddingBottom',local_source_style.paddingBottom);
				a_destination.ce_extension.change_style('visibility','');
			}");
			
			$this->header_script_generator->add_function_to_main_scope(
                "get_cookie","a_cname","
	var name = a_cname + \"=\";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    }
    return \"\";		
			");
			
            $this->header_script_generator->add_function_to_main_scope(
                "set_tag_property","a_properties_arr,a_value_arr,a_tag,a_raise_error"," 	
	if (typeof a_tag == 'object')
		var local_tag = a_tag;
	else	
		var local_tag = document.getElementById(a_tag);
	if ((local_tag != null) && (typeof local_tag == 'object'))
	{
		for(var i = 0; i<a_properties_arr.length; i++) 
		{
			local_tag[a_properties_arr[i]] = a_value_arr[i];
		}
		return local_tag;
	}
	else
	{
		if (a_raise_error == true)
			window.cuteengine.add_err_log(undefined,'tag \"'+ a_tag +'\" not found');
		return null;
	}	
	");		
            $this->header_script_generator->add_function_to_main_scope(
                "set_tag_style_property","a_properties_arr,a_value_arr,a_tag,a_raise_error"," 	
	if (typeof a_tag == 'object')
		var local_tag = a_tag;
	else	
		var local_tag = document.getElementById(a_tag);
	if ((local_tag != null) && (typeof local_tag == 'object'))
	{
		for(var i = 0; i<a_properties_arr.length; i++) 
		{
			local_tag.style[a_properties_arr[i]] = a_value_arr[i];
		}
		return local_tag;
	}
	else
	{
		if (a_raise_error == true)
			window.cuteengine.add_err_log(undefined,'tag \"'+ a_tag +'\" not found');
		return null;
	}	
	");		
            $this->header_script_generator->add_function_to_main_scope(
                "sub_value_to_position_value","current_value,value_to_sub"," 
            return parseInt(current_value) - parseInt(value_to_sub) + 'px';");		
            
		}
		// G
        public function generate_all_javascript_script()
        {
           // echo "this->generate_all_javascript_script<br>";
			$local_return = '';
            $this->header_script_generator->generate_javascript_text_script($local_return);
			return $local_return;
        }
		
		
    }
   
?>    